import { reactive } from "vue";
import { getAllCompanyApi } from "@/api/managementCenter/departmentPersonnel";
import { getListApi } from "@/api/configCenter/outBoundAgent";
export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNumList",
    placeholder: "支持批量(空格/逗号隔开)"
  },

  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "代理商",
    keyName: "outWarehouseBrokerIdList",
    optionsRequest: getListApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  }),
  {
    type: "select",
    label: "对账状态",
    keyName: "checkingStatusList",
    optConfig: {
      label: "name",
      value: "code"
    },
    options: [
      {
        name: "未对账",
        code: 0
      },
      {
        name: "对账中",
        code: 1
      },
      {
        name: "已对账",
        code: 2
      }
    ],
    attrs: {
      mode: "multiple"
    }
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    attrs: {
      mode: "multiple"
    },
    options: []
  })
];

export const tableColumn: Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem> = [
  {
    field: "waybillNum",
    title: "运单号",
    minWidth: "160"
  },
  {
    field: "outWarehouseBrokerName",
    title: "代理商",
    minWidth: "120"
  },
  {
    field: "companyName",
    title: "经营单位",
    minWidth: "120"
  },
  {
    field: "status",
    title: "运单状态",
    minWidth: "90",
    renderSlot: "status"
  },
  {
    field: "paymentAmount",
    title: "应付金额",
    minWidth: "120"
  },
  {
    field: "channelName",
    title: "入仓渠道",
    minWidth: "140"
  },
  {
    field: "agentChannelName",
    title: "出仓渠道",
    minWidth: "140"
  },
  {
    field: "checkingStatus",
    title: "对账状态",
    minWidth: "120",
    renderSlot: "checkingStatus"
  },
  {
    field: "action",
    title: "操作",
    minWidth: "120",
    fixed: "right",
    renderSlot: "action"
  }
];
